package com.yoosora.plugins;


import com.mikuac.shiro.annotation.MessageHandler;
import com.mikuac.shiro.core.Bot;
import com.mikuac.shiro.core.BotPlugin;
import com.mikuac.shiro.dto.event.message.WholeMessageEvent;
import com.yoosora.utils.ApiConst;
import com.yoosora.utils.RegexConst;
import com.yoosora.utils.RequestUtils;
import com.yoosora.utils.Strings;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.stereotype.Component;

import javax.validation.constraints.NotNull;

@Component
public class CommonsPlugin extends BotPlugin {

	private final static String HOLIDAY_PLAN="HOLIDAY_PLAN";

	@Autowired
	private RedisTemplate<String, String> redisTemplate;
	
	@MessageHandler(cmd = RegexConst.HOLIDAY_PLAN)
	public void holidayMsg(@NotNull Bot bot, @NotNull WholeMessageEvent event){
		String holidayPlan = redisTemplate.opsForValue().get(HOLIDAY_PLAN);
		if(!Strings.isNotEmpty(holidayPlan)){
			holidayPlan = "暂时没有放假信息呢~~";
		}
		bot.sendMsg(event, holidayPlan, false);
	}
	
	@MessageHandler(cmd = RegexConst.HITOKOTO)
	public void hitokotoMsg(@NotNull Bot bot, @NotNull WholeMessageEvent event){
		String result = RequestUtils.builder().get().build(ApiConst.HITOKOTO_API, Boolean.FALSE, null, null);
	}
	@MessageHandler(cmd = RegexConst.SEND_HELP)
	public void hlepMsg(@NotNull Bot bot, @NotNull WholeMessageEvent event){
		
	}
}
